Macintosh Toolbox
   HOME

TheInfoList



OR:

The Macintosh Toolbox implements many of the high-level features of the
Classic Mac OS Mac OS (originally System Software; retronym: Classic Mac OS) is the series of operating systems developed for the Macintosh family of personal computers by Apple Computer from 1984 to 2001, starting with System 1 and ending with Mac OS 9. The ...
, including a set of
application programming interface An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how t ...
s for software development on the platform. The Toolbox consists of a number of "managers," software components such as
QuickDraw A quickdraw (also known as an extender) is a piece of climbing equipment used by rock and ice climbers to allow the climbing rope to run freely through protection such as a bolt anchors or other traditional gear while leading. A quickdraw ...
, responsible for drawing onscreen graphics, and the Menu Manager, which maintain data structures describing the menu bar. As the original Macintosh was designed without
virtual memory In computing, virtual memory, or virtual storage is a memory management technique that provides an "idealized abstraction of the storage resources that are actually available on a given machine" which "creates the illusion to users of a very l ...
or
memory protection Memory protection is a way to control memory access rights on a computer, and is a part of most modern instruction set architectures and operating systems. The main purpose of memory protection is to prevent a process from accessing memory that h ...
, it was important to classify code according to when it should be loaded into memory or kept on disk, and how it should be accessed. The Toolbox consists of subroutines essential enough to be permanently kept in memory and accessible by a two-byte
machine instruction In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a very ...
; however it excludes core "kernel" functionality such as
memory management Memory management is a form of resource management applied to computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and free it for reuse when ...
and the
file system In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one larg ...
. Note that the Toolbox does not ''draw'' the menu onscreen: menus were designed to have a customizable appearance, so the drawing code was stored in a
resource Resource refers to all the materials available in our environment which are technologically accessible, economically feasible and culturally sustainable and help us to satisfy our needs and wants. Resources can broadly be classified upon their ...
, which could be on a disk.


Advent and implementation


On 68k systems

The original
Motorola 68000 family The Motorola 68000 series (also known as 680x0, m68000, m68k, or 68k) is a family of 32-bit complex instruction set computer (CISC) microprocessors. During the 1980s and early 1990s, they were popular in personal computers and workstations and ...
implementation of the Macintosh operating system executes system calls using that processor's
illegal opcode An illegal opcode, also called an unimplemented operation, unintended opcode or undocumented instruction, is an instruction to a CPU that is not mentioned in any official documentation released by the CPU's designer or manufacturer, which nev ...
exception handling In computing and computer programming, exception handling is the process of responding to the occurrence of ''exceptions'' – anomalous or exceptional conditions requiring special processing – during the execution of a program. In general, an ...
mechanism. Motorola specified that instructions beginning with ''1111'' and ''1010'' would never be used in future 68000 family processors, thus freeing them for use as such by an operating system. Further, they each had their own dedicated
interrupt vector An interrupt vector table (IVT) is a data structure that associates a list of interrupt handlers with a list of interrupt requests in a table of interrupt vectors. Each entry of the interrupt vector table, called an interrupt vector, is the addre ...
, separate from the generic illegal opcode handler. As ''1111'' was reserved for use by ''co''-processors such as the 68881 FPU, Apple chose ''1010'' (in the
hexadecimal In mathematics and computing, the hexadecimal (also base-16 or simply hex) numeral system is a positional numeral system that represents numbers using a radix (base) of 16. Unlike the decimal system representing numbers using 10 symbols, hexa ...
representation of
ASCII ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Because of ...
, an ''A'' followed by a control character) as the prefix for operating system calls. Handling illegal instructions is known as ''trapping'', so these special instructions were called ''A-traps''. When the processor encounters such an instruction, it transfers control to the operating system, which looks up the appropriate task and performs it. There were two advantages to this mechanism: * It results in compact programs. Only two
byte The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable unit ...
s are taken by every operating system access, in contrast to four or six when using regular
jump instruction A branch is an instruction in a computer program that can cause a computer to begin executing a different instruction sequence and thus deviate from its default behavior of executing instructions in order. ''Branch'' (or ''branching'', ''branc ...
s. * The table used to look up the appropriate function is stored in RAM. Then, even if the underlying code was stored in ROM, it could still be overridden (''
patched Patched (Ptc) is a conserved 12-pass transmembrane protein receptor that plays an obligate negative regulatory role in the Hedgehog signaling pathway in insects and vertebrates. Patched is an essential gene in embryogenesis for proper segme ...
'') by replacing the ROM
memory address In computing, a memory address is a reference to a specific memory location used at various levels by software and hardware. Memory addresses are fixed-length sequences of digits conventionally displayed and manipulated as unsigned integers. Su ...
with a RAM address. The system was further optimized by allotting some bits of the A-trap instruction to store
parameter A parameter (), generally, is any characteristic that can help in defining or classifying a particular system (meaning an event, project, object, situation, etc.). That is, a parameter is an element of a system that is useful, or critical, when ...
s to the most common functions. For example,
memory allocation Memory management is a form of Resource management (computing), resource management applied to computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their re ...
is a very common task, so it should be expressed in as few bytes of code as possible. Sometimes the programmer wants to clear the memory block to zeros, so either the allocation function should take a boolean parameter, or there should be two allocation functions. To pass a parameter would require an additional two-byte instruction, which would be inefficient. Having two functions would require at least an extra four bytes of RAM used for the address in the function look-up table. The most efficient solution is to map multiple A-traps to the same subroutine, which then uses the A-trap as a parameter. This is true of the most commonly used subroutines. However, the Toolbox was composed of the ''less'' commonly used subroutines. The Toolbox was defined as the set of subroutines which took no parameters within the A-trap, and were indexed from a 1024-entry, 4-kilobyte
dispatch table In computer science, a dispatch table is a table of pointers or memory addresses to functions or methods. Use of such a table is a common technique when implementing late binding in object-oriented programming. Perl implementation The followi ...
. (Machines shipped with less than one megabyte of RAM use a single table of 512 entries, which corresponds to the 256-entry OS dispatch table of later ROM revisions.)


On PowerPC systems

In 1994, Apple released Macintoshes using the
PowerPC PowerPC (with the backronym Performance Optimization With Enhanced RISC – Performance Computing, sometimes abbreviated as PPC) is a reduced instruction set computer (RISC) instruction set architecture (ISA) created by the 1991 Apple Inc., App ...
architecture, which lacked hardware support for the A-trap mechanism available on 68k systems. Because of their use in applying software patches, however, the dispatch tables were retained. The API library code underlying any Toolbox routine then does nothing except reference the dispatch table. The dispatch table linked only to emulated 68000 family code. Toolbox functions implemented in native PowerPC code have to first disable the emulator using the Mixed Mode Manager. For the sake of uniformity and extensibility, new function entries even continued to be added to the Toolbox after the PowerPC transition. An alternative mechanism did exist, however, in the Code Fragment Manager, which was used to load and dynamically link native PowerPC programs. The PowerPC system call facility, analogous to the A-trap mechanism, was used to interface with the
Mac OS nanokernel The Mac OS nanokernel is an operating system kernel serving as the basis of most PowerPC based system software versions 7 through 9 of the classic Mac OS, predating Mac OS X. The initial revision of this software is a single tasking system whic ...
, which offered few services directly useful to applications.


Functionality


Programming interfaces

The Toolbox is composed of commonly used functions, but not the ''most'' commonly used functions. As a result, it grew into a hodgepodge of different API
libraries A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vir ...
. The Toolbox encompasses most of the basic functionality which distinguished the Classic Mac OS. Apple's references “Inside Macintosh: Macintosh Toolbox Essentials” and “Inside Macintosh: More Macintosh Toolbox”, similarly vague in scope, also document most of the Toolbox.


Use in booting

Because much of the Toolbox is implemented in ROM, alongside the computer's
firmware In computing, firmware is a specific class of computer software that provides the low-level control for a device's specific hardware. Firmware, such as the BIOS of a personal computer, may contain basic functions of a device, and may provide h ...
, it was convenient to use as a
bootloader A bootloader, also spelled as boot loader or called boot manager and bootstrap loader, is a computer program that is responsible for booting a computer. When a computer is turned off, its softwareincluding operating systems, application code, an ...
environment. In conjunction with
resources Resource refers to all the materials available in our environment which are technologically accessible, economically feasible and culturally sustainable and help us to satisfy our needs and wants. Resources can broadly be classified upon their av ...
stored on the ROM chip, the Toolbox can turn the screen gray, show a dialog box with the signature "Welcome to Macintosh" greeting, and display the mouse cursor. By using Toolbox to help boot the machine, a rudimentary Mac-like environment can be initialized before ever loading the System suitcase from disk (in fact before ROMs on NuBus cards were executed), which is when the decision to use 24-bit or 32-bit addressing has to be made. (System 7's support for 32-bit addressing requires
32-bit clean Historically, the classic Mac OS used a form of memory management that has fallen out of favor in modern systems. Criticism of this approach was one of the key areas addressed by the change to . The original problem for the engineers of the Mac ...
ROMs, as older Mac ROMs do not have support for this). The need for diagnostics as in the
BIOS In computing, BIOS (, ; Basic Input/Output System, also known as the System BIOS, ROM BIOS, BIOS ROM or PC BIOS) is firmware used to provide runtime services for operating systems and programs and to perform hardware initialization during the ...
resident for
IBM PC compatible IBM PC compatible computers are similar to the original IBM PC, XT, and AT, all from computer giant IBM, that are able to use the same software and expansion cards. Such computers were referred to as PC clones, IBM clones or IBM PC clones. ...
s' boards is not necessary since the Macintosh has most of its diagnostics in
POST Post or POST commonly refers to: *Mail, the postal system, especially in Commonwealth of Nations countries **An Post, the Irish national postal service **Canada Post, Canadian postal service **Deutsche Post, German postal service **Iraqi Post, Ira ...
and automatically reports errors via the "
Sad Mac The classic Macintosh startup sequence includes hardware tests which may trigger the startup chime, Happy Mac, Sad Mac, and Chimes of Death. On Macs running macOS Big Sur or later the startup sound is enabled by default, but can be disabled by ...
" codes. The similarity between the boot-up environment and the actual operating system should not be confused with being identical, however. Although the "Classic Mac OS" boot process is convoluted and largely undocumented, it is not more limited than an
IBM PC compatible IBM PC compatible computers are similar to the original IBM PC, XT, and AT, all from computer giant IBM, that are able to use the same software and expansion cards. Such computers were referred to as PC clones, IBM clones or IBM PC clones. ...
BIOS. Like a PC's master boot record, a ROM-based Mac reads and executes code from the first blocks ("boot blocks") of the
disk partition Disk partitioning or disk slicing is the creation of one or more regions on secondary storage, so that each region can be managed separately. These regions are called partitions. It is typically the first step of preparing a newly installed disk ...
selected as the
boot device In computing, booting is the process of starting a computer as initiated via hardware such as a button or by a software command. After it is switched on, a computer's central processing unit (CPU) has no software in its main memory, so so ...
. The boot blocks then verify that a suitable rudimentary environment exists, and use it to load the System suitcase. A different operating system with a different
file system In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one larg ...
can boot by simply using its own code in the boot blocks.Alt URL
/ref> This system was not used for PowerPC Linux, however, because
Open Firmware Open Firmware is a standard defining the interfaces of a computer firmware system, formerly endorsed by the Institute of Electrical and Electronics Engineers (IEEE). It originated at Sun Microsystems, where it was known as OpenBoot, and has bee ...
in
New World ROM New World ROM computers are Macintosh models that do not use a Macintosh Toolbox ROM on the logic board. Due to Mac OS X not requiring the availability of the Toolbox, this allowed ROM sizes to shrink dramatically (typically from to ), and facilit ...
machines requires a bootloader within an HFS filesystem—a reason having nothing to do with the Toolbox or "old-fashioned" Macs in general. More narrowly, the Startup Disk control panel in the Classic Mac OS and macOS only allows the user to select a mounted filesystem with very particular constraints.


Legacy

In
Mac OS X macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac (computer), Mac computers. Within the market of ...
, the Toolbox is not used at all, though the
Classic Environment This is a list of macOS built-in apps and system components. Applications App Store The Mac App Store is macOS's digital distribution platform for macOS apps, created and maintained by Apple Inc. based on the iOS version, the platform was an ...
loads the Toolbox ROM file into its virtual machine. Much of the Toolbox was restructured and implemented as part of Apple's
Carbon Carbon () is a chemical element with the symbol C and atomic number 6. It is nonmetallic and tetravalent In chemistry, the valence (US spelling) or valency (British spelling) of an element is the measure of its combining capacity with o ...
programming API, allowing programmers familiar with the Toolbox to
port A port is a maritime facility comprising one or more wharves or loading areas, where ships load and discharge cargo and passengers. Although usually situated on a sea coast or estuary, ports can also be found far inland, such as Ham ...
their program code more easily to Mac OS X.


See also

*
Mac OS memory management Historically, the classic Mac OS used a form of memory management that has fallen out of favor in modern systems. Criticism of this approach was one of the key areas addressed by the change to . The original problem for the engineers of the Maci ...


References


External links


(PDF) Apple's ''Inside Macintosh: Macintosh Toolbox Essentials'' developer's guide
{{Widget toolkits Classic Mac OS Macintosh firmware